package service;

import dao.DepartmentDao;
import dao.impl.DepartmentDaoImpl;
import pojo.Department;
import util.Result;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class DepartmentService {

    private DepartmentDao dao = new DepartmentDaoImpl();

    /**
     * 查找所有部门
     * @param request
     * @param response
     */
    public void getAllDepartment(HttpServletRequest request, HttpServletResponse response){
        List<Department> departmentList = dao.findAllDepartment();
        if (departmentList==null) {
            Result.response(1001, "查找失败！", response);
            return;
        }
        Result.response(200, "success", response,departmentList);
    }

    /**
     * 查找可以修改的部门
     * @param request
     * @param response
     */
    public void getEditDepartment(HttpServletRequest request, HttpServletResponse response){
        List<Department> departmentList = dao.findEditDepartment();
        if (departmentList==null) {
            Result.response(1001, "查找失败！", response);
            return;
        }
        Result.response(200, "success", response,departmentList);
    }

}
